package com.zeedev.flyingsaucer.data;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.zeedev.flyingsaucer.global.UfoClubApp;
import mobi.zeedev.flyingsaucer.common.DataModule.MetaBeer;

public class BeerDataHelper extends BeerDataHelperBase {
	 
	private String TABLE_NAME;
    
    private UfoClubApp app;

	public static final String TAG = "BeerDataHelper";

    public BeerDataHelper(Context context, String dbNameIn, String tableNameIn, int versionIn) {
    	super(context, dbNameIn, null, versionIn);
        TABLE_NAME = tableNameIn;       
    }	

	public BeerDataHelper(Context context, String dbNameIn, int versionIn) {
		super(context, dbNameIn, null, versionIn);
	}

	
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		//Log.i(TAG,"Database create called.");
		if (TABLE_NAME != null) {
			MetaBeer mb = new MetaBeer();
	        db.execSQL(mb.generateCreateCommand(TABLE_NAME));
		}

        
        //Beers (Grand)
//        db.execSQL(BeerDataHelper.createStoresTable());
//        db.execSQL(BeerDataHelper.createStoresBeersTable());
//        db.execSQL(BeerDataHelper.createMemberBeersTable());
//        db.execSQL(BeerDataHelper.createBeersTable());
//        db.execSQL(BeerDataHelper.createMembersTable());

	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//Log.i(TAG,"Database upgrade called.");
        //Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
//        db.execSQL("DROP TABLE IF EXISTS " + StoresPreferencesModel.StoreBeer.TABLE);
//        db.execSQL("DROP TABLE IF EXISTS " + StoresPreferencesModel.TABLE);
//        db.execSQL("DROP TABLE IF EXISTS " + Beers.TABLE);
//        db.execSQL("DROP TABLE IF EXISTS " + Members.TABLE);
//        db.execSQL("DROP TABLE IF EXISTS " + MemberBeer.TABLE);
        onCreate(db);
	}

	@Override
	public void onOpen(SQLiteDatabase db) {
		super.onOpen(db);
	}
	
	
	
	
	
/*	

	private static final String createMemberBeersTable() {
		String[] PROPERTIES_LIST = {
				MemberBeer.MEMBER_BEER_KEY,
				MemberBeer.BEER_DB_ID,
				MemberBeer.MEMBER_DB_ID,
				MemberBeer.CREATION_DATE,
				MemberBeer.UPDATED_DATE,
				MemberBeer.ACTIVE,
				MemberBeer.COMMENTS,
				MemberBeer.RATING,
				MemberBeer.TASTED_DATE,
				
		};
		DB_TYPES[] TYPES_LIST = {
				DB_TYPES.DB_KEY_AUTO,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_BOOLEAN,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER
		};
		return genericCreateCommand(Members.MemberBeer.TABLE,PROPERTIES_LIST,TYPES_LIST);
		
	}
	
	private static final String createMembersTable() {
		String[] PROPERTIES_LIST = {
				Members.MEMBERS_KEY,
				Members.PASSWORD,
				Members.STORE_NUMBER,
				Members.CARD_NUMBER,
				Members.PASSWORD_HASH,
				Members.UFO_LOGIN_REMEMBER,
				Members.UFO_LOGIN_AUTO_LOGIN,
				Members.UFO_LOGIN_NON_MEMBER,
				Members.UFO_HOME_NUMBER_BEERS,
				Members.UFO_HOME_NUMBER_TOTAL_BEERS,
				Members.UFO_HOME_USERNAME,
				Members.UFO_HOME_NAME,
				Members.UFO_MEMBER_ID,
				Members.UFO_IS_CURRENT_USER,
				Members.CREATION_DATE,
				Members.UPDATED_DATE
		};
		DB_TYPES[] TYPES_LIST = {
				DB_TYPES.DB_KEY_AUTO,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_BOOLEAN,
				DB_TYPES.DB_BOOLEAN,
				DB_TYPES.DB_BOOLEAN,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_BOOLEAN,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER
				
		};
		return genericCreateCommand(Members.TABLE,PROPERTIES_LIST,TYPES_LIST);
		
	}

	public static final String createStoresBeersTable() {
		String[] PROPERTIES_LIST = {
				StoreBeer.STORE_BEER_KEY,
				StoresPreferencesModel.StoreBeer.BEER_DB_ID,
				StoresPreferencesModel.StoreBeer.STORE_DB_ID,
				StoresPreferencesModel.StoreBeer.CREATION_DATE,
				StoresPreferencesModel.StoreBeer.UPDATED_DATE,
				StoresPreferencesModel.StoreBeer.ACTIVE,
				
		};
		DB_TYPES[] TYPES_LIST = {
				DB_TYPES.DB_KEY_AUTO,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_BOOLEAN
		};
		return genericCreateCommand(StoreBeer.TABLE,PROPERTIES_LIST,TYPES_LIST);
		
	}
			
	public static final String createStoresTable() {
		
		String[] PROPERTIES_LIST = {
				StoresPreferencesModel.STORES_KEY,
				StoresPreferencesModel.NAME,
				StoresPreferencesModel.URL_NAME,
				StoresPreferencesModel.URL,
				StoresPreferencesModel.NUMBER,
				StoresPreferencesModel.UPDATED_DATE,
				StoresPreferencesModel.CREATION_DATE,
				StoresPreferencesModel.REFRESHED_BEERS
		};
		DB_TYPES[] TYPES_LIST = {
				DB_TYPES.DB_KEY_AUTO,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_STRING,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER,
				DB_TYPES.DB_INTEGER
		};
		return genericCreateCommand(StoresPreferencesModel.TABLE,PROPERTIES_LIST,TYPES_LIST);
	}
	
	public static final String createBeersTable() {
		final String[] PROPERTIES_LIST = { 
			Beers.BEER_ID, Beers.COUNTRY_ID, Beers.BREWER_ID, Beers.STYLE_ID,
			Beers.RAW_NAME, Beers.NAME, Beers.NAME_SUBSCRIPT,
			Beers.CONTAINER, Beers.BOTTLE, Beers.DRAUGHT, Beers.CAN,
//			Beers.DATE_ADDED, Beers.SIMPLE_DATE, Beers.TASTED,
			Beers.DESCRIPTION, Beers.CITY, Beers.COUNTRY_NAME,
			Beers.STYLE_NAME, Beers.BREWER_NAME, 
//			Beers.COMMENTS, Beers.RATING, 
			Beers.AVERAGE_RATING,	
			Beers.BEERS_KEY
//			Beers.INTERNAL_DATE_ADDED,  , Beers.MEMBER_ID, Beers.STATUS
			};
	
	final DB_TYPES[] TYPES_LIST = { 
		DB_TYPES.DB_INTEGER, DB_TYPES.DB_INTEGER, DB_TYPES.DB_INTEGER, DB_TYPES.DB_INTEGER,
		DB_TYPES.DB_STRING, DB_TYPES.DB_STRING, DB_TYPES.DB_STRING,
		DB_TYPES.DB_STRING, DB_TYPES.DB_BOOLEAN, DB_TYPES.DB_BOOLEAN, DB_TYPES.DB_BOOLEAN,
//		DB_TYPES.DB_DATE, DB_TYPES.DB_STRING, DB_TYPES.DB_BOOLEAN,
		DB_TYPES.DB_STRING, DB_TYPES.DB_STRING, DB_TYPES.DB_STRING,
		DB_TYPES.DB_STRING, DB_TYPES.DB_STRING, 
		//DB_TYPES.DB_STRING, DB_TYPES.DB_INTEGER, 
		DB_TYPES.DB_INTEGER,
		DB_TYPES.DB_KEY_AUTO
//		DB_TYPES.DB_DATE, 
		
//		DB_TYPES.DB_INTEGER, DB_TYPES.DB_STRING
		};
	
		return genericCreateCommand(Beers.TABLE,PROPERTIES_LIST,TYPES_LIST);
	}
	
	
*/
	
	
	

	
	
	




 
}